﻿#region License

// // -------------------------------------------------------------------------------------
// // This information refers to AggregateEventCountByContextValueResponse.cs
// // 
// // Copyright 2012 ELEN7046 Group 2
// // 
// // Last Modified on: 2012-06-10
// // 
// // Contributors:
// // 
// // Amith Sewnarain
// // Elmar Vosloo
// // Jason Thorne
// // Satish Jewan
// // 
// // Wits University 
// // School of Electrical & Information Engineering
// // Software Engineering Tools and Techniques
// // 
// // -------------------------------------------------------------------------------------
// // 
// // This file (AggregateEventCountByContextValueResponse.cs) is part of the DishDash Event Visualization System.
// // 
// // DishDash is free software: you can redistribute it and/or modify
// // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// // (at your option) any later version.
// // 
// // DishDash is distributed in the hope that it will be useful,
// // but WITHOUT ANY WARRANTY; without even the implied warranty of
// // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// // GNU General Public License for more details.
// // 
// // You should have received a copy of the GNU General Public License
// // along with DishDash.  
// // If not, see <http://www.gnu.org/licenses/>.
// // -------------------------------------------------------------------------------------

#endregion

#region Using Directives

using System.Collections.Generic;

#endregion

namespace DishDash.Handlers.Messages.EventMessages
{
    /// <summary>
    ///   Response to group all instances of the specified events that are in a sample period for the value of a context key and return the number thereof.
    /// </summary>
    public class AggregateEventCountByContextValueResponse
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="AggregateEventCountByContextValueResponse"/> class.
        /// </summary>
        public AggregateEventCountByContextValueResponse()
        {
            EventCounts = new List<Event>();
        }

#warning RENAME
        /// <summary>
        ///   Gets or sets the event data collection.
        /// </summary>
        /// <value> The event counts. </value>
        public List<Event> EventCounts { get; set; }
    }

    /// <summary>
    ///   Equality comparer used to sort events
    /// </summary>
    public class EventCountEqualityComparer : IEqualityComparer<EventCount>
    {
        #region IEqualityComparer<EventCount> Members

        /// <summary>
        /// Determines whether the specified objects are equal.
        /// </summary>
        /// <param name="x">The first object of type <paramref name="T"/> to compare.</param>
        /// <param name="y">The second object of type <paramref name="T"/> to compare.</param>
        /// <returns>
        /// true if the specified objects are equal; otherwise, false.
        /// </returns>
        public bool Equals(EventCount x, EventCount y)
        {
            if (x.TimeStamp == y.TimeStamp)
            {
                return true;
            }

            return false;
        }

        /// <summary>
        /// Returns a hash code for this instance.
        /// </summary>
        /// <param name="obj">The obj.</param>
        /// <returns>
        /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. 
        /// </returns>
        /// <exception cref="T:System.ArgumentNullException">
        /// The type of <paramref name="obj"/> is a reference type and <paramref name="obj"/> is null.
        ///   </exception>
        public int GetHashCode(EventCount obj)
        {
            return obj.GetHashCode();
        }

        #endregion
    }


    /// <summary>
    ///   Represents datapoints captured for an event
    /// </summary>
    public class Event
    {
        /// <summary>
        ///   Gets or sets the name of the event.
        /// </summary>
        /// <value> The name of the event. </value>
        public string EventName { get; set; }
#warning RENAME
        /// <summary>
        ///   Gets or sets the data points for this event.
        /// </summary>
        /// <value> The event counts. </value>
        public List<EventCount> EventCounts { get; set; }
    }

#warning RENAME
    /// <summary>
    ///   Represents a data point for an event
    /// </summary>
    public class EventCount
    {
        /// <summary>
        ///   Gets or sets the time stamp.
        /// </summary>
        /// <value> The time stamp. </value>
        public long TimeStamp { get; set; }

        /// <summary>
        ///   Gets or sets the count.
        /// </summary>
        /// <value> The count. </value>
        public long Count { get; set; }

        /// <summary>
        ///   Returns a <see cref="System.String" /> that represents this instance.
        /// </summary>
        /// <returns> A <see cref="System.String" /> that represents this instance. </returns>
        public override string ToString()
        {
            return string.Format("TimeStamp : {0}, Count {1}", TimeStamp, Count);
        }
    }
}